library(cregg)
library(ggplot2)
library(ggpubr)
rm(list=ls())

#### Load data 

load("data.RData")

#### Formulas for models

f1 <- vote_choice ~ age + prof+career + gender + legeff + voteror + voterknow + smedia ## Formula
f2 <- better_pol ~ age + prof+career + gender + legeff + voteror + voterknow + smedia ## Formula
f3 <- prob_vote ~ age + prof+career + gender + legeff + voteror + voterknow + smedia ## Formula


### Run models by age group

data4 <- data[is.na(data$Age_group)==F & data$country!="Switzerland" & data$country!="Germany",]


acmes.vote_choice_1834 <- cj(data4[data4$Age_group=="18-34",], f1, id = ~id)
acmes.better_pol_1834 <- cj(data4[data4$Age_group=="18-34",], f2, id = ~id)
acmes.prob_vote_1834 <- cj(data4[data4$Age_group=="18-34",], f3, id = ~id)



acmes.vote_choice_3550 <- cj(data4[data4$Age_group=="35-49",], f1, id = ~id)
acmes.better_pol_3550 <- cj(data4[data4$Age_group=="35-49",], f2, id = ~id)
acmes.prob_vote_3550 <- cj(data4[data4$Age_group=="35-49",], f3, id = ~id)


acmes.vote_choice_5065 <- cj(data4[data4$Age_group=="50-65",], f1, id = ~id)
acmes.better_pol_5065 <- cj(data4[data4$Age_group=="50-65",], f2, id = ~id)
acmes.prob_vote_5065 <- cj(data4[data4$Age_group=="50-65",], f3, id = ~id)

acmes.vote_choice_65 <- cj(data4[data4$Age_group=="65+",], f1, id = ~id)
acmes.better_pol_65 <- cj(data4[data4$Age_group=="65+",], f2, id = ~id)
acmes.prob_vote_65 <- cj(data4[data4$Age_group=="65+",], f3, id = ~id)




mm.vote_choice_1834 <- mm(data4[data4$Age_group=="18-34",], f1, id = ~id)
mm.better_pol_1834 <- mm(data4[data4$Age_group=="18-34",], f2, id = ~id)
mm.prob_vote_1834 <- mm(data4[data4$Age_group=="18-34",], f3, id = ~id)



mm.vote_choice_3550 <- mm(data4[data4$Age_group=="35-49",], f1, id = ~id)
mm.better_pol_3550 <- mm(data4[data4$Age_group=="35-49",], f2, id = ~id)
mm.prob_vote_3550 <- mm(data4[data4$Age_group=="35-49",], f3, id = ~id)


mm.vote_choice_5065 <- mm(data4[data4$Age_group=="50-65",], f1, id = ~id)
mm.better_pol_5065 <- mm(data4[data4$Age_group=="50-65",], f2, id = ~id)
mm.prob_vote_5065 <- mm(data4[data4$Age_group=="50-65",], f3, id = ~id)

mm.vote_choice_65 <- mm(data4[data4$Age_group=="65+",], f1, id = ~id)
mm.better_pol_65 <- mm(data4[data4$Age_group=="65+",], f2, id = ~id)
mm.prob_vote_65 <- mm(data4[data4$Age_group=="65+",], f3, id = ~id)


### Create data Figure A12


acmes.vote_choice_1834$Age <- "18-34"
acmes.vote_choice_3550$Age <- "35-49"
acmes.vote_choice_5065$Age <- "50-65"
acmes.vote_choice_65$Age <- "65+"


acmes.vote_choice_age <- rbind(acmes.vote_choice_1834, acmes.vote_choice_3550, acmes.vote_choice_5065, acmes.vote_choice_65)

mm.vote_choice_1834$Age <- "18-34"
mm.vote_choice_3550$Age <- "35-49"
mm.vote_choice_5065$Age <- "50-65"
mm.vote_choice_65$Age <- "65+"


mm.vote_choice_age <- rbind(mm.vote_choice_1834, mm.vote_choice_3550, mm.vote_choice_5065, mm.vote_choice_65)



Age_data_acmes.vote_choice <- as.data.frame(list(labels = rep(c("Age", "33", "43", "53", "63", "73",
                                                                "Profession", "Buisness Person", "Farmer", "Lawyer", "Medical doctor", "Parliamentary assistant",
                                                                "Career", "Joined party 3 years ago", "Party offices in last 15 years",
                                                                "Gender", "Man", "Woman",
                                                                "Legislative Effectiveness", "Successful in parliament", "Not very successful in parliament",
                                                                "Presence in Constituency", "Rarely in constituency", "Often in constituency",
                                                                "Knowledge of voters", "Does not know voters well", "Knows voters well",
                                                                "Social Media", "Communicates regularly", "Does not communicate often"),4),
                                                 labels_score = rep(c(13:30,1:12), 4),
                                                 estimate = c(NA, acmes.vote_choice_age$estimate[1:5],
                                                              NA, acmes.vote_choice_age$estimate[6:10],
                                                              NA, acmes.vote_choice_age$estimate[11:12],
                                                              NA, acmes.vote_choice_age$estimate[13:14],
                                                              NA, acmes.vote_choice_age$estimate[15:16],
                                                              NA, acmes.vote_choice_age$estimate[17:18],
                                                              NA, acmes.vote_choice_age$estimate[19:20],
                                                              NA, acmes.vote_choice_age$estimate[21:22],
                                                              NA, acmes.vote_choice_age$estimate[22+1:5],
                                                              NA, acmes.vote_choice_age$estimate[22+6:10],
                                                              NA, acmes.vote_choice_age$estimate[22+11:12],
                                                              NA, acmes.vote_choice_age$estimate[22+13:14],
                                                              NA, acmes.vote_choice_age$estimate[22+15:16],
                                                              NA, acmes.vote_choice_age$estimate[22+17:18],
                                                              NA, acmes.vote_choice_age$estimate[22+19:20],
                                                              NA, acmes.vote_choice_age$estimate[22+21:22],
                                                              NA, acmes.vote_choice_age$estimate[44+1:5],
                                                              NA, acmes.vote_choice_age$estimate[44+6:10],
                                                              NA, acmes.vote_choice_age$estimate[44+11:12],
                                                              NA, acmes.vote_choice_age$estimate[44+13:14],
                                                              NA, acmes.vote_choice_age$estimate[44+15:16],
                                                              NA, acmes.vote_choice_age$estimate[44+17:18],
                                                              NA, acmes.vote_choice_age$estimate[44+19:20],
                                                              NA, acmes.vote_choice_age$estimate[44+21:22],
                                                              NA, acmes.vote_choice_age$estimate[66+1:5],
                                                              NA, acmes.vote_choice_age$estimate[66+6:10],
                                                              NA, acmes.vote_choice_age$estimate[66+11:12],
                                                              NA, acmes.vote_choice_age$estimate[66+13:14],
                                                              NA, acmes.vote_choice_age$estimate[66+15:16],
                                                              NA, acmes.vote_choice_age$estimate[66+17:18],
                                                              NA, acmes.vote_choice_age$estimate[66+19:20],
                                                              NA, acmes.vote_choice_age$estimate[66+21:22]),
                                                 
                                                 lower = c(NA, NA, acmes.vote_choice_age$lower[2:5],
                                                           NA, NA, acmes.vote_choice_age$lower[7:10],
                                                           NA, NA, acmes.vote_choice_age$lower[12],
                                                           NA, NA, acmes.vote_choice_age$lower[14],
                                                           NA, NA, acmes.vote_choice_age$lower[16],
                                                           NA, NA, acmes.vote_choice_age$lower[18],
                                                           NA, NA, acmes.vote_choice_age$lower[20],
                                                           NA, NA, acmes.vote_choice_age$lower[22],
                                                           NA, NA, acmes.vote_choice_age$lower[22+2:5],
                                                           NA, NA, acmes.vote_choice_age$lower[22+7:10],
                                                           NA, NA, acmes.vote_choice_age$lower[22+12],
                                                           NA, NA, acmes.vote_choice_age$lower[22+14],
                                                           NA, NA, acmes.vote_choice_age$lower[22+16],
                                                           NA, NA, acmes.vote_choice_age$lower[22+18],
                                                           NA, NA, acmes.vote_choice_age$lower[22+20],
                                                           NA, NA, acmes.vote_choice_age$lower[22+22],
                                                           NA, NA, acmes.vote_choice_age$lower[44+2:5],
                                                           NA, NA, acmes.vote_choice_age$lower[44+7:10],
                                                           NA, NA, acmes.vote_choice_age$lower[44+12],
                                                           NA, NA, acmes.vote_choice_age$lower[44+14],
                                                           NA, NA, acmes.vote_choice_age$lower[44+16],
                                                           NA, NA, acmes.vote_choice_age$lower[44+18],
                                                           NA, NA, acmes.vote_choice_age$lower[44+20],
                                                           NA, NA, acmes.vote_choice_age$lower[44+22],
                                                           NA, NA, acmes.vote_choice_age$lower[66+2:5],
                                                           NA, NA, acmes.vote_choice_age$lower[66+7:10],
                                                           NA, NA, acmes.vote_choice_age$lower[66+12],
                                                           NA, NA, acmes.vote_choice_age$lower[66+14],
                                                           NA, NA, acmes.vote_choice_age$lower[66+16],
                                                           NA, NA, acmes.vote_choice_age$lower[66+18],
                                                           NA, NA, acmes.vote_choice_age$lower[66+20],
                                                           NA, NA, acmes.vote_choice_age$lower[66+22]),
                                                 upper = c(NA, NA, acmes.vote_choice_age$upper[2:5],
                                                           NA, NA, acmes.vote_choice_age$upper[7:10],
                                                           NA, NA, acmes.vote_choice_age$upper[12],
                                                           NA, NA, acmes.vote_choice_age$upper[14],
                                                           NA, NA, acmes.vote_choice_age$upper[16],
                                                           NA, NA, acmes.vote_choice_age$upper[18],
                                                           NA, NA, acmes.vote_choice_age$upper[20],
                                                           NA, NA, acmes.vote_choice_age$upper[22],
                                                           NA, NA, acmes.vote_choice_age$upper[22+2:5],
                                                           NA, NA, acmes.vote_choice_age$upper[22+7:10],
                                                           NA, NA, acmes.vote_choice_age$upper[22+12],
                                                           NA, NA, acmes.vote_choice_age$upper[22+14],
                                                           NA, NA, acmes.vote_choice_age$upper[22+16],
                                                           NA, NA, acmes.vote_choice_age$upper[22+18],
                                                           NA, NA, acmes.vote_choice_age$upper[22+20],
                                                           NA, NA, acmes.vote_choice_age$upper[22+22],
                                                           NA, NA, acmes.vote_choice_age$upper[44+2:5],
                                                           NA, NA, acmes.vote_choice_age$upper[44+7:10],
                                                           NA, NA, acmes.vote_choice_age$upper[44+12],
                                                           NA, NA, acmes.vote_choice_age$upper[44+14],
                                                           NA, NA, acmes.vote_choice_age$upper[44+16],
                                                           NA, NA, acmes.vote_choice_age$upper[44+18],
                                                           NA, NA, acmes.vote_choice_age$upper[44+20],
                                                           NA, NA, acmes.vote_choice_age$upper[44+22],
                                                           NA, NA, acmes.vote_choice_age$upper[66+2:5],
                                                           NA, NA, acmes.vote_choice_age$upper[66+7:10],
                                                           NA, NA, acmes.vote_choice_age$upper[66+12],
                                                           NA, NA, acmes.vote_choice_age$upper[66+14],
                                                           NA, NA, acmes.vote_choice_age$upper[66+16],
                                                           NA, NA, acmes.vote_choice_age$upper[66+18],
                                                           NA, NA, acmes.vote_choice_age$upper[66+20],
                                                           NA, NA, acmes.vote_choice_age$upper[66+22]),
                                                 Age = rep(c("18-34", "35-49", "50-65", "65+"), each=30),
                                                 Age_score = rep(c(0:3), each=30)))




Age_data_mm.vote_choice <- as.data.frame(list(labels = rep(c("Age", "33", "43", "53", "63", "73",
                                                             "Profession", "Buisness Person", "Farmer", "Lawyer", "Medical doctor", "Parliamentary assistant",
                                                             "Career", "Joined party 3 years ago", "Party offices in last 15 years",
                                                             "Gender", "Man", "Woman",
                                                             "Legislative Effectiveness", "Successful in parliament", "Not very successful in parliament",
                                                             "Presence in Constituency", "Rarely in constituency", "Often in constituency",
                                                             "Knowledge of voters", "Does not know voters well", "Knows voters well",
                                                             "Social Media", "Communicates regularly", "Does not communicate often"),4),
                                              labels_score = rep(c(13:30,1:12), 4),
                                              estimate = c(NA, mm.vote_choice_age$estimate[1:5],
                                                           NA, mm.vote_choice_age$estimate[6:10],
                                                           NA, mm.vote_choice_age$estimate[11:12],
                                                           NA, mm.vote_choice_age$estimate[13:14],
                                                           NA, mm.vote_choice_age$estimate[15:16],
                                                           NA, mm.vote_choice_age$estimate[17:18],
                                                           NA, mm.vote_choice_age$estimate[19:20],
                                                           NA, mm.vote_choice_age$estimate[21:22],
                                                           NA, mm.vote_choice_age$estimate[22+1:5],
                                                           NA, mm.vote_choice_age$estimate[22+6:10],
                                                           NA, mm.vote_choice_age$estimate[22+11:12],
                                                           NA, mm.vote_choice_age$estimate[22+13:14],
                                                           NA, mm.vote_choice_age$estimate[22+15:16],
                                                           NA, mm.vote_choice_age$estimate[22+17:18],
                                                           NA, mm.vote_choice_age$estimate[22+19:20],
                                                           NA, mm.vote_choice_age$estimate[22+21:22],
                                                           NA, mm.vote_choice_age$estimate[44+1:5],
                                                           NA, mm.vote_choice_age$estimate[44+6:10],
                                                           NA, mm.vote_choice_age$estimate[44+11:12],
                                                           NA, mm.vote_choice_age$estimate[44+13:14],
                                                           NA, mm.vote_choice_age$estimate[44+15:16],
                                                           NA, mm.vote_choice_age$estimate[44+17:18],
                                                           NA, mm.vote_choice_age$estimate[44+19:20],
                                                           NA, mm.vote_choice_age$estimate[44+21:22],
                                                           NA, mm.vote_choice_age$estimate[66+1:5],
                                                           NA, mm.vote_choice_age$estimate[66+6:10],
                                                           NA, mm.vote_choice_age$estimate[66+11:12],
                                                           NA, mm.vote_choice_age$estimate[66+13:14],
                                                           NA, mm.vote_choice_age$estimate[66+15:16],
                                                           NA, mm.vote_choice_age$estimate[66+17:18],
                                                           NA, mm.vote_choice_age$estimate[66+19:20],
                                                           NA, mm.vote_choice_age$estimate[66+21:22]),
                                              
                                              lower = c(NA, mm.vote_choice_age$lower[1:5],
                                                        NA, mm.vote_choice_age$lower[6:10],
                                                        NA, mm.vote_choice_age$lower[11:12],
                                                        NA, mm.vote_choice_age$lower[13:14],
                                                        NA, mm.vote_choice_age$lower[15:16],
                                                        NA, mm.vote_choice_age$lower[17:18],
                                                        NA, mm.vote_choice_age$lower[19:20],
                                                        NA, mm.vote_choice_age$lower[21:22],
                                                        NA, mm.vote_choice_age$lower[22+1:5],
                                                        NA, mm.vote_choice_age$lower[22+6:10],
                                                        NA, mm.vote_choice_age$lower[22+11:12],
                                                        NA, mm.vote_choice_age$lower[22+13:14],
                                                        NA, mm.vote_choice_age$lower[22+15:16],
                                                        NA, mm.vote_choice_age$lower[22+17:18],
                                                        NA, mm.vote_choice_age$lower[22+19:20],
                                                        NA, mm.vote_choice_age$lower[22+21:22],
                                                        NA, mm.vote_choice_age$lower[44+1:5],
                                                        NA, mm.vote_choice_age$lower[44+6:10],
                                                        NA, mm.vote_choice_age$lower[44+11:12],
                                                        NA, mm.vote_choice_age$lower[44+13:14],
                                                        NA, mm.vote_choice_age$lower[44+15:16],
                                                        NA, mm.vote_choice_age$lower[44+17:18],
                                                        NA, mm.vote_choice_age$lower[44+19:20],
                                                        NA, mm.vote_choice_age$lower[44+21:22],
                                                        NA, mm.vote_choice_age$lower[66+1:5],
                                                        NA, mm.vote_choice_age$lower[66+6:10],
                                                        NA, mm.vote_choice_age$lower[66+11:12],
                                                        NA, mm.vote_choice_age$lower[66+13:14],
                                                        NA, mm.vote_choice_age$lower[66+15:16],
                                                        NA, mm.vote_choice_age$lower[66+17:18],
                                                        NA, mm.vote_choice_age$lower[66+19:20],
                                                        NA, mm.vote_choice_age$lower[66+21:22]),
                                              upper = c(NA, mm.vote_choice_age$upper[1:5],
                                                        NA, mm.vote_choice_age$upper[6:10],
                                                        NA, mm.vote_choice_age$upper[11:12],
                                                        NA, mm.vote_choice_age$upper[13:14],
                                                        NA, mm.vote_choice_age$upper[15:16],
                                                        NA, mm.vote_choice_age$upper[17:18],
                                                        NA, mm.vote_choice_age$upper[19:20],
                                                        NA, mm.vote_choice_age$upper[21:22],
                                                        NA, mm.vote_choice_age$upper[22+1:5],
                                                        NA, mm.vote_choice_age$upper[22+6:10],
                                                        NA, mm.vote_choice_age$upper[22+11:12],
                                                        NA, mm.vote_choice_age$upper[22+13:14],
                                                        NA, mm.vote_choice_age$upper[22+15:16],
                                                        NA, mm.vote_choice_age$upper[22+17:18],
                                                        NA, mm.vote_choice_age$upper[22+19:20],
                                                        NA, mm.vote_choice_age$upper[22+21:22],
                                                        NA, mm.vote_choice_age$upper[44+1:5],
                                                        NA, mm.vote_choice_age$upper[44+6:10],
                                                        NA, mm.vote_choice_age$upper[44+11:12],
                                                        NA, mm.vote_choice_age$upper[44+13:14],
                                                        NA, mm.vote_choice_age$upper[44+15:16],
                                                        NA, mm.vote_choice_age$upper[44+17:18],
                                                        NA, mm.vote_choice_age$upper[44+19:20],
                                                        NA, mm.vote_choice_age$upper[44+21:22],
                                                        NA, mm.vote_choice_age$upper[66+1:5],
                                                        NA, mm.vote_choice_age$upper[66+6:10],
                                                        NA, mm.vote_choice_age$upper[66+11:12],
                                                        NA, mm.vote_choice_age$upper[66+13:14],
                                                        NA, mm.vote_choice_age$upper[66+15:16],
                                                        NA, mm.vote_choice_age$upper[66+17:18],
                                                        NA, mm.vote_choice_age$upper[66+19:20],
                                                        NA, mm.vote_choice_age$upper[66+21:22]),
                                              Age = rep(c("18-34", "35-49", "50-65", "65+"), each=30),
                                              Age_score = rep(c(0:3), each=30)))

Age_data_acmes.vote_choice$type <- "Acmes"
Age_data_mm.vote_choice$type <- "Marginal Means"


Age_data_acmes.vote_choice$labels_score2 <- as.numeric(paste0(Age_data_acmes.vote_choice$labels_score, ".", Age_data_acmes.vote_choice$Age_score))
Age_data_mm.vote_choice$labels_score2 <- as.numeric(paste0(Age_data_mm.vote_choice$labels_score, ".", Age_data_mm.vote_choice$Age_score))


### Create data Figure A13



acmes.better_pol_1834$Age <- "18-34"
acmes.better_pol_3550$Age <- "35-49"
acmes.better_pol_5065$Age <- "50-65"
acmes.better_pol_65$Age <- "65+"


acmes.better_pol_age <- rbind(acmes.better_pol_1834, acmes.better_pol_3550, acmes.better_pol_5065, acmes.better_pol_65)

mm.better_pol_1834$Age <- "18-34"
mm.better_pol_3550$Age <- "35-49"
mm.better_pol_5065$Age <- "50-65"
mm.better_pol_65$Age <- "65+"


mm.better_pol_age <- rbind(mm.better_pol_1834, mm.better_pol_3550, mm.better_pol_5065, mm.better_pol_65)




Age_data_acmes.better_pol <- as.data.frame(list(labels = rep(c("Age", "33", "43", "53", "63", "73",
                                                               "Profession", "Buisness Person", "Farmer", "Lawyer", "Medical doctor", "Parliamentary assistant",
                                                               "Career", "Joined party 3 years ago", "Party offices in last 15 years",
                                                               "Gender", "Man", "Woman",
                                                               "Legislative Effectiveness", "Successful in parliament", "Not very successful in parliament",
                                                               "Presence in Constituency", "Rarely in constituency", "Often in constituency",
                                                               "Knowledge of voters", "Does not know voters well", "Knows voters well",
                                                               "Social Media", "Communicates regularly", "Does not communicate often"),4),
                                                labels_score = rep(c(13:30,1:12), 4),
                                                estimate = c(NA, acmes.better_pol_age$estimate[1:5],
                                                             NA, acmes.better_pol_age$estimate[6:10],
                                                             NA, acmes.better_pol_age$estimate[11:12],
                                                             NA, acmes.better_pol_age$estimate[13:14],
                                                             NA, acmes.better_pol_age$estimate[15:16],
                                                             NA, acmes.better_pol_age$estimate[17:18],
                                                             NA, acmes.better_pol_age$estimate[19:20],
                                                             NA, acmes.better_pol_age$estimate[21:22],
                                                             NA, acmes.better_pol_age$estimate[22+1:5],
                                                             NA, acmes.better_pol_age$estimate[22+6:10],
                                                             NA, acmes.better_pol_age$estimate[22+11:12],
                                                             NA, acmes.better_pol_age$estimate[22+13:14],
                                                             NA, acmes.better_pol_age$estimate[22+15:16],
                                                             NA, acmes.better_pol_age$estimate[22+17:18],
                                                             NA, acmes.better_pol_age$estimate[22+19:20],
                                                             NA, acmes.better_pol_age$estimate[22+21:22],
                                                             NA, acmes.better_pol_age$estimate[44+1:5],
                                                             NA, acmes.better_pol_age$estimate[44+6:10],
                                                             NA, acmes.better_pol_age$estimate[44+11:12],
                                                             NA, acmes.better_pol_age$estimate[44+13:14],
                                                             NA, acmes.better_pol_age$estimate[44+15:16],
                                                             NA, acmes.better_pol_age$estimate[44+17:18],
                                                             NA, acmes.better_pol_age$estimate[44+19:20],
                                                             NA, acmes.better_pol_age$estimate[44+21:22],
                                                             NA, acmes.better_pol_age$estimate[66+1:5],
                                                             NA, acmes.better_pol_age$estimate[66+6:10],
                                                             NA, acmes.better_pol_age$estimate[66+11:12],
                                                             NA, acmes.better_pol_age$estimate[66+13:14],
                                                             NA, acmes.better_pol_age$estimate[66+15:16],
                                                             NA, acmes.better_pol_age$estimate[66+17:18],
                                                             NA, acmes.better_pol_age$estimate[66+19:20],
                                                             NA, acmes.better_pol_age$estimate[66+21:22]),
                                                
                                                lower = c(NA, NA, acmes.better_pol_age$lower[2:5],
                                                          NA, NA, acmes.better_pol_age$lower[7:10],
                                                          NA, NA, acmes.better_pol_age$lower[12],
                                                          NA, NA, acmes.better_pol_age$lower[14],
                                                          NA, NA, acmes.better_pol_age$lower[16],
                                                          NA, NA, acmes.better_pol_age$lower[18],
                                                          NA, NA, acmes.better_pol_age$lower[20],
                                                          NA, NA, acmes.better_pol_age$lower[22],
                                                          NA, NA, acmes.better_pol_age$lower[22+2:5],
                                                          NA, NA, acmes.better_pol_age$lower[22+7:10],
                                                          NA, NA, acmes.better_pol_age$lower[22+12],
                                                          NA, NA, acmes.better_pol_age$lower[22+14],
                                                          NA, NA, acmes.better_pol_age$lower[22+16],
                                                          NA, NA, acmes.better_pol_age$lower[22+18],
                                                          NA, NA, acmes.better_pol_age$lower[22+20],
                                                          NA, NA, acmes.better_pol_age$lower[22+22],
                                                          NA, NA, acmes.better_pol_age$lower[44+2:5],
                                                          NA, NA, acmes.better_pol_age$lower[44+7:10],
                                                          NA, NA, acmes.better_pol_age$lower[44+12],
                                                          NA, NA, acmes.better_pol_age$lower[44+14],
                                                          NA, NA, acmes.better_pol_age$lower[44+16],
                                                          NA, NA, acmes.better_pol_age$lower[44+18],
                                                          NA, NA, acmes.better_pol_age$lower[44+20],
                                                          NA, NA, acmes.better_pol_age$lower[44+22],
                                                          NA, NA, acmes.better_pol_age$lower[66+2:5],
                                                          NA, NA, acmes.better_pol_age$lower[66+7:10],
                                                          NA, NA, acmes.better_pol_age$lower[66+12],
                                                          NA, NA, acmes.better_pol_age$lower[66+14],
                                                          NA, NA, acmes.better_pol_age$lower[66+16],
                                                          NA, NA, acmes.better_pol_age$lower[66+18],
                                                          NA, NA, acmes.better_pol_age$lower[66+20],
                                                          NA, NA, acmes.better_pol_age$lower[66+22]),
                                                upper = c(NA, NA, acmes.better_pol_age$upper[2:5],
                                                          NA, NA, acmes.better_pol_age$upper[7:10],
                                                          NA, NA, acmes.better_pol_age$upper[12],
                                                          NA, NA, acmes.better_pol_age$upper[14],
                                                          NA, NA, acmes.better_pol_age$upper[16],
                                                          NA, NA, acmes.better_pol_age$upper[18],
                                                          NA, NA, acmes.better_pol_age$upper[20],
                                                          NA, NA, acmes.better_pol_age$upper[22],
                                                          NA, NA, acmes.better_pol_age$upper[22+2:5],
                                                          NA, NA, acmes.better_pol_age$upper[22+7:10],
                                                          NA, NA, acmes.better_pol_age$upper[22+12],
                                                          NA, NA, acmes.better_pol_age$upper[22+14],
                                                          NA, NA, acmes.better_pol_age$upper[22+16],
                                                          NA, NA, acmes.better_pol_age$upper[22+18],
                                                          NA, NA, acmes.better_pol_age$upper[22+20],
                                                          NA, NA, acmes.better_pol_age$upper[22+22],
                                                          NA, NA, acmes.better_pol_age$upper[44+2:5],
                                                          NA, NA, acmes.better_pol_age$upper[44+7:10],
                                                          NA, NA, acmes.better_pol_age$upper[44+12],
                                                          NA, NA, acmes.better_pol_age$upper[44+14],
                                                          NA, NA, acmes.better_pol_age$upper[44+16],
                                                          NA, NA, acmes.better_pol_age$upper[44+18],
                                                          NA, NA, acmes.better_pol_age$upper[44+20],
                                                          NA, NA, acmes.better_pol_age$upper[44+22],
                                                          NA, NA, acmes.better_pol_age$upper[66+2:5],
                                                          NA, NA, acmes.better_pol_age$upper[66+7:10],
                                                          NA, NA, acmes.better_pol_age$upper[66+12],
                                                          NA, NA, acmes.better_pol_age$upper[66+14],
                                                          NA, NA, acmes.better_pol_age$upper[66+16],
                                                          NA, NA, acmes.better_pol_age$upper[66+18],
                                                          NA, NA, acmes.better_pol_age$upper[66+20],
                                                          NA, NA, acmes.better_pol_age$upper[66+22]),
                                                Age = rep(c("18-34", "35-49", "50-65", "65+"), each=30),
                                                Age_score = rep(c(0:3), each=30)))




Age_data_mm.better_pol <- as.data.frame(list(labels = rep(c("Age", "33", "43", "53", "63", "73",
                                                            "Profession", "Buisness Person", "Farmer", "Lawyer", "Medical doctor", "Parliamentary assistant",
                                                            "Career", "Joined party 3 years ago", "Party offices in last 15 years",
                                                            "Gender", "Man", "Woman",
                                                            "Legislative Effectiveness", "Successful in parliament", "Not very successful in parliament",
                                                            "Presence in Constituency", "Rarely in constituency", "Often in constituency",
                                                            "Knowledge of voters", "Does not know voters well", "Knows voters well",
                                                            "Social Media", "Communicates regularly", "Does not communicate often"),4),
                                             labels_score = rep(c(13:30,1:12), 4),
                                             estimate = c(NA, mm.better_pol_age$estimate[1:5],
                                                          NA, mm.better_pol_age$estimate[6:10],
                                                          NA, mm.better_pol_age$estimate[11:12],
                                                          NA, mm.better_pol_age$estimate[13:14],
                                                          NA, mm.better_pol_age$estimate[15:16],
                                                          NA, mm.better_pol_age$estimate[17:18],
                                                          NA, mm.better_pol_age$estimate[19:20],
                                                          NA, mm.better_pol_age$estimate[21:22],
                                                          NA, mm.better_pol_age$estimate[22+1:5],
                                                          NA, mm.better_pol_age$estimate[22+6:10],
                                                          NA, mm.better_pol_age$estimate[22+11:12],
                                                          NA, mm.better_pol_age$estimate[22+13:14],
                                                          NA, mm.better_pol_age$estimate[22+15:16],
                                                          NA, mm.better_pol_age$estimate[22+17:18],
                                                          NA, mm.better_pol_age$estimate[22+19:20],
                                                          NA, mm.better_pol_age$estimate[22+21:22],
                                                          NA, mm.better_pol_age$estimate[44+1:5],
                                                          NA, mm.better_pol_age$estimate[44+6:10],
                                                          NA, mm.better_pol_age$estimate[44+11:12],
                                                          NA, mm.better_pol_age$estimate[44+13:14],
                                                          NA, mm.better_pol_age$estimate[44+15:16],
                                                          NA, mm.better_pol_age$estimate[44+17:18],
                                                          NA, mm.better_pol_age$estimate[44+19:20],
                                                          NA, mm.better_pol_age$estimate[44+21:22],
                                                          NA, mm.better_pol_age$estimate[66+1:5],
                                                          NA, mm.better_pol_age$estimate[66+6:10],
                                                          NA, mm.better_pol_age$estimate[66+11:12],
                                                          NA, mm.better_pol_age$estimate[66+13:14],
                                                          NA, mm.better_pol_age$estimate[66+15:16],
                                                          NA, mm.better_pol_age$estimate[66+17:18],
                                                          NA, mm.better_pol_age$estimate[66+19:20],
                                                          NA, mm.better_pol_age$estimate[66+21:22]),
                                             
                                             lower = c(NA, mm.better_pol_age$lower[1:5],
                                                       NA, mm.better_pol_age$lower[6:10],
                                                       NA, mm.better_pol_age$lower[11:12],
                                                       NA, mm.better_pol_age$lower[13:14],
                                                       NA, mm.better_pol_age$lower[15:16],
                                                       NA, mm.better_pol_age$lower[17:18],
                                                       NA, mm.better_pol_age$lower[19:20],
                                                       NA, mm.better_pol_age$lower[21:22],
                                                       NA, mm.better_pol_age$lower[22+1:5],
                                                       NA, mm.better_pol_age$lower[22+6:10],
                                                       NA, mm.better_pol_age$lower[22+11:12],
                                                       NA, mm.better_pol_age$lower[22+13:14],
                                                       NA, mm.better_pol_age$lower[22+15:16],
                                                       NA, mm.better_pol_age$lower[22+17:18],
                                                       NA, mm.better_pol_age$lower[22+19:20],
                                                       NA, mm.better_pol_age$lower[22+21:22],
                                                       NA, mm.better_pol_age$lower[44+1:5],
                                                       NA, mm.better_pol_age$lower[44+6:10],
                                                       NA, mm.better_pol_age$lower[44+11:12],
                                                       NA, mm.better_pol_age$lower[44+13:14],
                                                       NA, mm.better_pol_age$lower[44+15:16],
                                                       NA, mm.better_pol_age$lower[44+17:18],
                                                       NA, mm.better_pol_age$lower[44+19:20],
                                                       NA, mm.better_pol_age$lower[44+21:22],
                                                       NA, mm.better_pol_age$lower[66+1:5],
                                                       NA, mm.better_pol_age$lower[66+6:10],
                                                       NA, mm.better_pol_age$lower[66+11:12],
                                                       NA, mm.better_pol_age$lower[66+13:14],
                                                       NA, mm.better_pol_age$lower[66+15:16],
                                                       NA, mm.better_pol_age$lower[66+17:18],
                                                       NA, mm.better_pol_age$lower[66+19:20],
                                                       NA, mm.better_pol_age$lower[66+21:22]),
                                             upper = c(NA, mm.better_pol_age$upper[1:5],
                                                       NA, mm.better_pol_age$upper[6:10],
                                                       NA, mm.better_pol_age$upper[11:12],
                                                       NA, mm.better_pol_age$upper[13:14],
                                                       NA, mm.better_pol_age$upper[15:16],
                                                       NA, mm.better_pol_age$upper[17:18],
                                                       NA, mm.better_pol_age$upper[19:20],
                                                       NA, mm.better_pol_age$upper[21:22],
                                                       NA, mm.better_pol_age$upper[22+1:5],
                                                       NA, mm.better_pol_age$upper[22+6:10],
                                                       NA, mm.better_pol_age$upper[22+11:12],
                                                       NA, mm.better_pol_age$upper[22+13:14],
                                                       NA, mm.better_pol_age$upper[22+15:16],
                                                       NA, mm.better_pol_age$upper[22+17:18],
                                                       NA, mm.better_pol_age$upper[22+19:20],
                                                       NA, mm.better_pol_age$upper[22+21:22],
                                                       NA, mm.better_pol_age$upper[44+1:5],
                                                       NA, mm.better_pol_age$upper[44+6:10],
                                                       NA, mm.better_pol_age$upper[44+11:12],
                                                       NA, mm.better_pol_age$upper[44+13:14],
                                                       NA, mm.better_pol_age$upper[44+15:16],
                                                       NA, mm.better_pol_age$upper[44+17:18],
                                                       NA, mm.better_pol_age$upper[44+19:20],
                                                       NA, mm.better_pol_age$upper[44+21:22],
                                                       NA, mm.better_pol_age$upper[66+1:5],
                                                       NA, mm.better_pol_age$upper[66+6:10],
                                                       NA, mm.better_pol_age$upper[66+11:12],
                                                       NA, mm.better_pol_age$upper[66+13:14],
                                                       NA, mm.better_pol_age$upper[66+15:16],
                                                       NA, mm.better_pol_age$upper[66+17:18],
                                                       NA, mm.better_pol_age$upper[66+19:20],
                                                       NA, mm.better_pol_age$upper[66+21:22]),
                                             Age = rep(c("18-34", "35-49", "50-65", "65+"), each=30),
                                             Age_score = rep(c(0:3), each=30)))

Age_data_acmes.better_pol$type <- "Acmes"
Age_data_mm.better_pol$type <- "Marginal Means"

Age_data_acmes.better_pol$labels_score2 <- as.numeric(paste0(Age_data_acmes.better_pol$labels_score, ".", Age_data_acmes.better_pol$Age_score))
Age_data_mm.better_pol$labels_score2 <- as.numeric(paste0(Age_data_mm.better_pol$labels_score, ".", Age_data_mm.better_pol$Age_score))



### Create data Figure A14



acmes.prob_vote_1834$Age <- "18-34"
acmes.prob_vote_3550$Age <- "35-49"
acmes.prob_vote_5065$Age <- "50-65"
acmes.prob_vote_65$Age <- "65+"


acmes.prob_vote_age <- rbind(acmes.prob_vote_1834, acmes.prob_vote_3550, acmes.prob_vote_5065, acmes.prob_vote_65)

mm.prob_vote_1834$Age <- "18-34"
mm.prob_vote_3550$Age <- "35-49"
mm.prob_vote_5065$Age <- "50-65"
mm.prob_vote_65$Age <- "65+"


mm.prob_vote_age <- rbind(mm.prob_vote_1834, mm.prob_vote_3550, mm.prob_vote_5065, mm.prob_vote_65)




Age_data_acmes.prob_vote <- as.data.frame(list(labels = rep(c("Age", "33", "43", "53", "63", "73",
                                                              "Profession", "Buisness Person", "Farmer", "Lawyer", "Medical doctor", "Parliamentary assistant",
                                                              "Career", "Joined party 3 years ago", "Party offices in last 15 years",
                                                              "Gender", "Man", "Woman",
                                                              "Legislative Effectiveness", "Successful in parliament", "Not very successful in parliament",
                                                              "Presence in Constituency", "Rarely in constituency", "Often in constituency",
                                                              "Knowledge of voters", "Does not know voters well", "Knows voters well",
                                                              "Social Media", "Communicates regularly", "Does not communicate often"),4),
                                               labels_score = rep(c(13:30,1:12), 4),
                                               estimate = c(NA, acmes.prob_vote_age$estimate[1:5],
                                                            NA, acmes.prob_vote_age$estimate[6:10],
                                                            NA, acmes.prob_vote_age$estimate[11:12],
                                                            NA, acmes.prob_vote_age$estimate[13:14],
                                                            NA, acmes.prob_vote_age$estimate[15:16],
                                                            NA, acmes.prob_vote_age$estimate[17:18],
                                                            NA, acmes.prob_vote_age$estimate[19:20],
                                                            NA, acmes.prob_vote_age$estimate[21:22],
                                                            NA, acmes.prob_vote_age$estimate[22+1:5],
                                                            NA, acmes.prob_vote_age$estimate[22+6:10],
                                                            NA, acmes.prob_vote_age$estimate[22+11:12],
                                                            NA, acmes.prob_vote_age$estimate[22+13:14],
                                                            NA, acmes.prob_vote_age$estimate[22+15:16],
                                                            NA, acmes.prob_vote_age$estimate[22+17:18],
                                                            NA, acmes.prob_vote_age$estimate[22+19:20],
                                                            NA, acmes.prob_vote_age$estimate[22+21:22],
                                                            NA, acmes.prob_vote_age$estimate[44+1:5],
                                                            NA, acmes.prob_vote_age$estimate[44+6:10],
                                                            NA, acmes.prob_vote_age$estimate[44+11:12],
                                                            NA, acmes.prob_vote_age$estimate[44+13:14],
                                                            NA, acmes.prob_vote_age$estimate[44+15:16],
                                                            NA, acmes.prob_vote_age$estimate[44+17:18],
                                                            NA, acmes.prob_vote_age$estimate[44+19:20],
                                                            NA, acmes.prob_vote_age$estimate[44+21:22],
                                                            NA, acmes.prob_vote_age$estimate[66+1:5],
                                                            NA, acmes.prob_vote_age$estimate[66+6:10],
                                                            NA, acmes.prob_vote_age$estimate[66+11:12],
                                                            NA, acmes.prob_vote_age$estimate[66+13:14],
                                                            NA, acmes.prob_vote_age$estimate[66+15:16],
                                                            NA, acmes.prob_vote_age$estimate[66+17:18],
                                                            NA, acmes.prob_vote_age$estimate[66+19:20],
                                                            NA, acmes.prob_vote_age$estimate[66+21:22]),
                                               
                                               lower = c(NA, NA, acmes.prob_vote_age$lower[2:5],
                                                         NA, NA, acmes.prob_vote_age$lower[7:10],
                                                         NA, NA, acmes.prob_vote_age$lower[12],
                                                         NA, NA, acmes.prob_vote_age$lower[14],
                                                         NA, NA, acmes.prob_vote_age$lower[16],
                                                         NA, NA, acmes.prob_vote_age$lower[18],
                                                         NA, NA, acmes.prob_vote_age$lower[20],
                                                         NA, NA, acmes.prob_vote_age$lower[22],
                                                         NA, NA, acmes.prob_vote_age$lower[22+2:5],
                                                         NA, NA, acmes.prob_vote_age$lower[22+7:10],
                                                         NA, NA, acmes.prob_vote_age$lower[22+12],
                                                         NA, NA, acmes.prob_vote_age$lower[22+14],
                                                         NA, NA, acmes.prob_vote_age$lower[22+16],
                                                         NA, NA, acmes.prob_vote_age$lower[22+18],
                                                         NA, NA, acmes.prob_vote_age$lower[22+20],
                                                         NA, NA, acmes.prob_vote_age$lower[22+22],
                                                         NA, NA, acmes.prob_vote_age$lower[44+2:5],
                                                         NA, NA, acmes.prob_vote_age$lower[44+7:10],
                                                         NA, NA, acmes.prob_vote_age$lower[44+12],
                                                         NA, NA, acmes.prob_vote_age$lower[44+14],
                                                         NA, NA, acmes.prob_vote_age$lower[44+16],
                                                         NA, NA, acmes.prob_vote_age$lower[44+18],
                                                         NA, NA, acmes.prob_vote_age$lower[44+20],
                                                         NA, NA, acmes.prob_vote_age$lower[44+22],
                                                         NA, NA, acmes.prob_vote_age$lower[66+2:5],
                                                         NA, NA, acmes.prob_vote_age$lower[66+7:10],
                                                         NA, NA, acmes.prob_vote_age$lower[66+12],
                                                         NA, NA, acmes.prob_vote_age$lower[66+14],
                                                         NA, NA, acmes.prob_vote_age$lower[66+16],
                                                         NA, NA, acmes.prob_vote_age$lower[66+18],
                                                         NA, NA, acmes.prob_vote_age$lower[66+20],
                                                         NA, NA, acmes.prob_vote_age$lower[66+22]),
                                               upper = c(NA, NA, acmes.prob_vote_age$upper[2:5],
                                                         NA, NA, acmes.prob_vote_age$upper[7:10],
                                                         NA, NA, acmes.prob_vote_age$upper[12],
                                                         NA, NA, acmes.prob_vote_age$upper[14],
                                                         NA, NA, acmes.prob_vote_age$upper[16],
                                                         NA, NA, acmes.prob_vote_age$upper[18],
                                                         NA, NA, acmes.prob_vote_age$upper[20],
                                                         NA, NA, acmes.prob_vote_age$upper[22],
                                                         NA, NA, acmes.prob_vote_age$upper[22+2:5],
                                                         NA, NA, acmes.prob_vote_age$upper[22+7:10],
                                                         NA, NA, acmes.prob_vote_age$upper[22+12],
                                                         NA, NA, acmes.prob_vote_age$upper[22+14],
                                                         NA, NA, acmes.prob_vote_age$upper[22+16],
                                                         NA, NA, acmes.prob_vote_age$upper[22+18],
                                                         NA, NA, acmes.prob_vote_age$upper[22+20],
                                                         NA, NA, acmes.prob_vote_age$upper[22+22],
                                                         NA, NA, acmes.prob_vote_age$upper[44+2:5],
                                                         NA, NA, acmes.prob_vote_age$upper[44+7:10],
                                                         NA, NA, acmes.prob_vote_age$upper[44+12],
                                                         NA, NA, acmes.prob_vote_age$upper[44+14],
                                                         NA, NA, acmes.prob_vote_age$upper[44+16],
                                                         NA, NA, acmes.prob_vote_age$upper[44+18],
                                                         NA, NA, acmes.prob_vote_age$upper[44+20],
                                                         NA, NA, acmes.prob_vote_age$upper[44+22],
                                                         NA, NA, acmes.prob_vote_age$upper[66+2:5],
                                                         NA, NA, acmes.prob_vote_age$upper[66+7:10],
                                                         NA, NA, acmes.prob_vote_age$upper[66+12],
                                                         NA, NA, acmes.prob_vote_age$upper[66+14],
                                                         NA, NA, acmes.prob_vote_age$upper[66+16],
                                                         NA, NA, acmes.prob_vote_age$upper[66+18],
                                                         NA, NA, acmes.prob_vote_age$upper[66+20],
                                                         NA, NA, acmes.prob_vote_age$upper[66+22]),
                                               Age = rep(c("18-34", "35-49", "50-65", "65+"), each=30),
                                               Age_score = rep(c(0:3), each=30)))




Age_data_mm.prob_vote <- as.data.frame(list(labels = rep(c("Age", "33", "43", "53", "63", "73",
                                                           "Profession", "Buisness Person", "Farmer", "Lawyer", "Medical doctor", "Parliamentary assistant",
                                                           "Career", "Joined party 3 years ago", "Party offices in last 15 years",
                                                           "Gender", "Man", "Woman",
                                                           "Legislative Effectiveness", "Successful in parliament", "Not very successful in parliament",
                                                           "Presence in Constituency", "Rarely in constituency", "Often in constituency",
                                                           "Knowledge of voters", "Does not know voters well", "Knows voters well",
                                                           "Social Media", "Communicates regularly", "Does not communicate often"),4),
                                            labels_score = rep(c(13:30,1:12), 4),
                                            estimate = c(NA, mm.prob_vote_age$estimate[1:5],
                                                         NA, mm.prob_vote_age$estimate[6:10],
                                                         NA, mm.prob_vote_age$estimate[11:12],
                                                         NA, mm.prob_vote_age$estimate[13:14],
                                                         NA, mm.prob_vote_age$estimate[15:16],
                                                         NA, mm.prob_vote_age$estimate[17:18],
                                                         NA, mm.prob_vote_age$estimate[19:20],
                                                         NA, mm.prob_vote_age$estimate[21:22],
                                                         NA, mm.prob_vote_age$estimate[22+1:5],
                                                         NA, mm.prob_vote_age$estimate[22+6:10],
                                                         NA, mm.prob_vote_age$estimate[22+11:12],
                                                         NA, mm.prob_vote_age$estimate[22+13:14],
                                                         NA, mm.prob_vote_age$estimate[22+15:16],
                                                         NA, mm.prob_vote_age$estimate[22+17:18],
                                                         NA, mm.prob_vote_age$estimate[22+19:20],
                                                         NA, mm.prob_vote_age$estimate[22+21:22],
                                                         NA, mm.prob_vote_age$estimate[44+1:5],
                                                         NA, mm.prob_vote_age$estimate[44+6:10],
                                                         NA, mm.prob_vote_age$estimate[44+11:12],
                                                         NA, mm.prob_vote_age$estimate[44+13:14],
                                                         NA, mm.prob_vote_age$estimate[44+15:16],
                                                         NA, mm.prob_vote_age$estimate[44+17:18],
                                                         NA, mm.prob_vote_age$estimate[44+19:20],
                                                         NA, mm.prob_vote_age$estimate[44+21:22],
                                                         NA, mm.prob_vote_age$estimate[66+1:5],
                                                         NA, mm.prob_vote_age$estimate[66+6:10],
                                                         NA, mm.prob_vote_age$estimate[66+11:12],
                                                         NA, mm.prob_vote_age$estimate[66+13:14],
                                                         NA, mm.prob_vote_age$estimate[66+15:16],
                                                         NA, mm.prob_vote_age$estimate[66+17:18],
                                                         NA, mm.prob_vote_age$estimate[66+19:20],
                                                         NA, mm.prob_vote_age$estimate[66+21:22]),
                                            
                                            lower = c(NA, mm.prob_vote_age$lower[1:5],
                                                      NA, mm.prob_vote_age$lower[6:10],
                                                      NA, mm.prob_vote_age$lower[11:12],
                                                      NA, mm.prob_vote_age$lower[13:14],
                                                      NA, mm.prob_vote_age$lower[15:16],
                                                      NA, mm.prob_vote_age$lower[17:18],
                                                      NA, mm.prob_vote_age$lower[19:20],
                                                      NA, mm.prob_vote_age$lower[21:22],
                                                      NA, mm.prob_vote_age$lower[22+1:5],
                                                      NA, mm.prob_vote_age$lower[22+6:10],
                                                      NA, mm.prob_vote_age$lower[22+11:12],
                                                      NA, mm.prob_vote_age$lower[22+13:14],
                                                      NA, mm.prob_vote_age$lower[22+15:16],
                                                      NA, mm.prob_vote_age$lower[22+17:18],
                                                      NA, mm.prob_vote_age$lower[22+19:20],
                                                      NA, mm.prob_vote_age$lower[22+21:22],
                                                      NA, mm.prob_vote_age$lower[44+1:5],
                                                      NA, mm.prob_vote_age$lower[44+6:10],
                                                      NA, mm.prob_vote_age$lower[44+11:12],
                                                      NA, mm.prob_vote_age$lower[44+13:14],
                                                      NA, mm.prob_vote_age$lower[44+15:16],
                                                      NA, mm.prob_vote_age$lower[44+17:18],
                                                      NA, mm.prob_vote_age$lower[44+19:20],
                                                      NA, mm.prob_vote_age$lower[44+21:22],
                                                      NA, mm.prob_vote_age$lower[66+1:5],
                                                      NA, mm.prob_vote_age$lower[66+6:10],
                                                      NA, mm.prob_vote_age$lower[66+11:12],
                                                      NA, mm.prob_vote_age$lower[66+13:14],
                                                      NA, mm.prob_vote_age$lower[66+15:16],
                                                      NA, mm.prob_vote_age$lower[66+17:18],
                                                      NA, mm.prob_vote_age$lower[66+19:20],
                                                      NA, mm.prob_vote_age$lower[66+21:22]),
                                            upper = c(NA, mm.prob_vote_age$upper[1:5],
                                                      NA, mm.prob_vote_age$upper[6:10],
                                                      NA, mm.prob_vote_age$upper[11:12],
                                                      NA, mm.prob_vote_age$upper[13:14],
                                                      NA, mm.prob_vote_age$upper[15:16],
                                                      NA, mm.prob_vote_age$upper[17:18],
                                                      NA, mm.prob_vote_age$upper[19:20],
                                                      NA, mm.prob_vote_age$upper[21:22],
                                                      NA, mm.prob_vote_age$upper[22+1:5],
                                                      NA, mm.prob_vote_age$upper[22+6:10],
                                                      NA, mm.prob_vote_age$upper[22+11:12],
                                                      NA, mm.prob_vote_age$upper[22+13:14],
                                                      NA, mm.prob_vote_age$upper[22+15:16],
                                                      NA, mm.prob_vote_age$upper[22+17:18],
                                                      NA, mm.prob_vote_age$upper[22+19:20],
                                                      NA, mm.prob_vote_age$upper[22+21:22],
                                                      NA, mm.prob_vote_age$upper[44+1:5],
                                                      NA, mm.prob_vote_age$upper[44+6:10],
                                                      NA, mm.prob_vote_age$upper[44+11:12],
                                                      NA, mm.prob_vote_age$upper[44+13:14],
                                                      NA, mm.prob_vote_age$upper[44+15:16],
                                                      NA, mm.prob_vote_age$upper[44+17:18],
                                                      NA, mm.prob_vote_age$upper[44+19:20],
                                                      NA, mm.prob_vote_age$upper[44+21:22],
                                                      NA, mm.prob_vote_age$upper[66+1:5],
                                                      NA, mm.prob_vote_age$upper[66+6:10],
                                                      NA, mm.prob_vote_age$upper[66+11:12],
                                                      NA, mm.prob_vote_age$upper[66+13:14],
                                                      NA, mm.prob_vote_age$upper[66+15:16],
                                                      NA, mm.prob_vote_age$upper[66+17:18],
                                                      NA, mm.prob_vote_age$upper[66+19:20],
                                                      NA, mm.prob_vote_age$upper[66+21:22]),
                                            Age = rep(c("18-34", "35-49", "50-65", "65+"), each=30),
                                            Age_score = rep(c(0:3), each=30)))

Age_data_acmes.prob_vote$type <- "Acmes"
Age_data_mm.prob_vote$type <- "Marginal Means"

Age_data_acmes.prob_vote$labels_score2 <- as.numeric(paste0(Age_data_acmes.prob_vote$labels_score, ".", Age_data_acmes.prob_vote$Age_score))
Age_data_mm.prob_vote$labels_score2 <- as.numeric(paste0(Age_data_mm.prob_vote$labels_score, ".", Age_data_mm.prob_vote$Age_score))


### Plot Figure A12


png("Figures/Figure A12.png", width = 2500, height = 3000, res=300)
ggplot(rbind(Age_data_acmes.vote_choice, Age_data_mm.vote_choice))+
  geom_point(aes(x=estimate, y=labels_score2, color = Age))+
  geom_errorbarh(aes(xmin = lower, xmax=upper, color = Age, y=labels_score2), height = 0.1)+
  scale_y_continuous(breaks = c(1:30), labels = unique(as.character(Age_data_acmes.vote_choice$labels))[c(19:30,1:18)],
                     trans = "reverse")+
  scale_color_manual(values = c("red", "blue", "grey", "dark green"))+
  ylab("")+
  facet_wrap(~type,
             labeller = labeller(
               type = c(`Marginal Means` = "Marginal Means", `Acmes` = "Average Marginal Component Effect")
             ), scales = 'free_x')+
  ylab("")+
  theme_minimal()+
  theme(legend.position = "bottom", 
        panel.border = element_rect(colour = "black", fill=NA, linewidth=.5), 
        axis.text.y = element_text(face = c("bold", rep("plain", 2), 
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 5),
                                            "bold", rep("plain", 5),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2))))
dev.off()


### Plot Figure A13



png("Figures/Figure A13.png", width = 2500, height = 3000, res=300)
ggplot(rbind(Age_data_acmes.better_pol, Age_data_mm.better_pol))+
  geom_point(aes(x=estimate, y=labels_score2, color = Age))+
  geom_errorbarh(aes(xmin = lower, xmax=upper, color = Age, y=labels_score2), height = 0.1)+
  scale_y_continuous(breaks = c(1:30), labels = unique(as.character(Age_data_acmes.better_pol$labels))[c(19:30,1:18)],
                     trans = "reverse")+
  scale_color_manual(values = c("red", "blue", "grey", "dark green"))+
  ylab("")+
  facet_wrap(~type,
             labeller = labeller(
               type = c(`Marginal Means` = "Marginal Means", `Acmes` = "Average Marginal Component Effect")
             ), scales = 'free_x')+
  ylab("")+
  theme_minimal()+
  theme(legend.position = "bottom", 
        panel.border = element_rect(colour = "black", fill=NA, linewidth=.5), 
        axis.text.y = element_text(face = c("bold", rep("plain", 2), 
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 5),
                                            "bold", rep("plain", 5),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2))))
dev.off()



### Plot Figure A14


png("Figures/Figure A14.png", width = 2500, height = 3000, res=300)
ggplot(rbind(Age_data_acmes.prob_vote, Age_data_mm.prob_vote))+
  geom_point(aes(x=estimate, y=labels_score2, color = Age))+
  geom_errorbarh(aes(xmin = lower, xmax=upper, color = Age, y=labels_score2), height = 0.1)+
  scale_y_continuous(breaks = c(1:30), labels = unique(as.character(Age_data_acmes.prob_vote$labels))[c(19:30,1:18)],
                     trans = "reverse")+
  scale_color_manual(values = c("red", "blue", "grey", "dark green"))+
  ylab("")+
  facet_wrap(~type,
             labeller = labeller(
               type = c(`Marginal Means` = "Marginal Means", `Acmes` = "Average Marginal Component Effect")
             ), scales = 'free_x')+
  ylab("")+
  theme_minimal()+
  theme(legend.position = "bottom", 
        panel.border = element_rect(colour = "black", fill=NA, linewidth=.5), 
        axis.text.y = element_text(face = c("bold", rep("plain", 2), 
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 5),
                                            "bold", rep("plain", 5),
                                            "bold", rep("plain", 2),
                                            "bold", rep("plain", 2))))
dev.off()





